// 引入封装好的组件
import Button from "./Button/Button.vue";
import Message from "./Message/Message.js";
import Dialog from "./Dialog/Dialog.vue";
import Accordion from "./Accordion/Accordion.vue";
import AccordionItem from "./Accordion/AccordionItem.vue";
import Spin from "./Spin/Spin.vue";
import Space from "./Space/Space.vue";
import Pdf from "./Pdf/Pdf.vue";
import TextScroll from "./TextScroll/TextScroll.vue";
// 引入字体库
import "../../assets/iconfont/font_4395989_v0frhf1p96/iconfont.css";
//引入默认样式
import "../../assets/reset.css";
const COMPONENTS = [
  Button,
  Dialog,
  Accordion,
  AccordionItem,
  Spin,
  Space,
  Pdf,
  TextScroll,
];

/* 

使用按需加载引入
Vue.use("插件名称",{
    components:[
    "myButton",
    "myInput"
    ]
})
假如使用插件时候使用上面写法也可以实现按需加载
*/

/* 使用实现按需注册可以提供配置options */
const llsUI = {};
llsUI.install = function (Vue, options) {
  /* options是Vue.use("插件名称",{})的{}的对象参数就是上面配置的
{
    components:[
    "myButton",
    "myInput"
    ]
}对象

*/
  /* 挂载message */
  Vue.config.globalProperties.$message = Message;
  COMPONENTS.forEach((component) => {
    Vue.component(component.name, component);
  });
  // if (options && options.components) {
  /* 按需注入的另一个方式 前提使用是 Vue.use("插件名称",{})在{}里面填入需要引入的*/
  //   const components = options.components;
  //   components.forEach((componentName) => {
  //     COMPONENTS.forEach((component) => {
  //       if (componentName === component.name) {
  //         Vue.component(component.name, component);
  //       }
  //     });
  //   });
  // } else {
  //   COMPONENTS.forEach((component) => {
  //     Vue.component(component.name, component);
  //   });
  // }
};
export default llsUI;
/* 如果想实现import {xxx} from "xxx"这种方式按需加载组件 */

const myButton = {};
const myMessage = {};
const myDialog = {};
const myAccordion = {};
const myAccordionItem = {};
const mySpin = {};
const mySpace = {};
const myPdf = {};
const myTextScroll = {};
myButton.install = (Vue) => Vue.component(Button.name, Button);
myMessage.install = (Vue) => {
  Vue.config.globalProperties.$message = Message;
};
myDialog.install = (Vue) => Vue.component(Dialog.name, Dialog);
myAccordion.install = (Vue) => Vue.component(Accordion.name, Accordion);
myAccordionItem.install = (Vue) =>
  Vue.component(AccordionItem.name, AccordionItem);
mySpin.install = (Vue) => Vue.component(Spin.name, Spin);
mySpace.install = (Vue) => Vue.component(Space.name, Space);
myPdf.install = (Vue) => Vue.component(Pdf.name, Pdf);
myTextScroll.install = (Vue) => Vue.component(TextScroll.name, TextScroll);
export {
  myButton,
  myMessage,
  myDialog,
  myAccordion,
  myAccordionItem,
  mySpace,
  myPdf,
  myTextScroll,
};
